package com.student.servlet.admin;
//@Classname AdminListServlet
//@time 16:39
//OMEN

import com.alibaba.fastjson.JSON;

import com.student.dao.CountryDao;

import com.student.dao.impl.CountryDaoImpl;

import com.student.entity.Country;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/admin/country-list.let")
public class CountryListServlet extends HttpServlet {
    private CountryDao dao=new CountryDaoImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.reset();
        resp.setContentType("application/json;charset=UTF-8");


        try {
            List<Country> list= dao.select(0,999);
            resp.getWriter().print(JSON.toJSONString(list));


        }catch (Exception ex){
            throw new  ServletException(ex.getMessage(),ex);
        }
        resp.flushBuffer();
    }
}
